<h3 class="page-header">
  日报管理<%= "（搜索结果）" if @search_params %>
  <small>
    <%= link_to "填报日报", new_ssp_report_path %>
    <a href="#" data-toggle="modal" data-target="#advanced-search">高级搜索</a>
    <%= link_to "清空过滤条件", ssp_reports_path if @search_params %>
    <%= link_to "导出Excel", ssp_reports_path(format: :xlsx, search: @search_params && @search_params.permit!.to_h) %>
    <% if @search_params.nil? %>
      <span class="pull-right">默认显示最近一年的数据，请使用 “<a href="#" data-toggle="modal" data-target="#advanced-search">高级搜索</a>” 查看更多</span>
    <% end %>
  </small>
</h3>

<!-- Modal -->
<div class="modal fade" id="advanced-search" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</span></button>
        <h4 class="modal-title">高级搜索</h4>
      </div>
      <%= simple_form_for :search, method: :get do |f| %>
        <div class="modal-body">
          <% if current_user.admin %>
            <%= f.input :nickname_or_ssid, label: '站点编码或站点名称', required: false, input_html: { value: @nickname_or_ssid } %>
            <%= f.input :sstype, label: '站点类型', required: false, selected: @sstype, collection: { "" => "" }.merge(Ssp::User::SSTYPES) %>
          <% end %>
          <%= f.input :status, label: '日报状态', required: false, selected: @status, collection: { "" => "" }.merge(Ssp::Report::STATUS) %>
          <%= f.label :publish_at_daterange, '报表日期', required: false %>
          <div class='row datetimerange'>
            <%= f.input :publish_at_from, label: false, required: false, as: :date_picker, wrapper: :ranged_datetime, input_html: { value: @publish_at_from } %>
            <%= f.input :publish_at_to, label: false, required: false, as: :date_picker, wrapper: :ranged_datetime, input_html: { value: @publish_at_to } %>
          </div>
          <%= f.label :created_at_daterange, '填报时间', required: false %>
          <div class='row datetimerange'>
            <%= f.input :created_at_from, label: false, required: false, as: :date_picker, wrapper: :ranged_datetime, input_html: { value: @created_at_from } %>
            <%= f.input :created_at_to, label: false, required: false, as: :date_picker, wrapper: :ranged_datetime, input_html: { value: @created_at_to } %>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
          <button type="submit" class="btn btn-primary">搜索</button>
        </div>
      <% end %>
    </div>
  </div>
</div>

<%= render partial: 'table', layout: current_user.admin ? 'sidebar' : false %>
